# # import cufflinks as cf
# #
# # cf.set_config_file(offline=True, world_readable=True)
# #
# #
# # import cufflinks as cf
# # cf.set_config_file(offline=True, world_readable=True)
# # df=cf.datagen.ohlcv()#cufflinks提供的数据，也可以更改为自定义数据
# # qf=cf.QuantFig(df,title='cufflinks金融绘图样例',legend='top',name='QF')
# # qf.add_dmi(periods=5)
# # qf.iplot()
# # import plotly as py
# # import plotly.graph_objs as go
# #
# # fig = go.Figure()
# # print(len(fig))
# # # print(fig[0])
# #
# #
# import sys
#
# sys.path.append("D:\myquant-demo")
#
# import datetime
# import numpy as np
# import pandas as pd
# import plotly as py
# import plotly.graph_objs as go
#
# import cufflinks as cf
# from cufflinks.plotlytools import iplot as pt_iplot
#
# from pyutils.utils_datetime import datetime_2_datetime64
# from actions.load_datas import csv_path, load_local_stock_datas, reorganize_datas
#
# py.offline.init_notebook_mode()
#
# datas = load_local_stock_datas(csv_path)
# datas = reorganize_datas(datas)
#
#
# # print(datas)
#
# def get_break(df: pd.DataFrame):
#     # removing all empty dates
#     # build complete timeline from start date to end date
#     dt_all = pd.date_range(start=df.index[0], end=df.index[-1])
#     # retrieve the dates that ARE in the original datset
#     dt_obs = [d.strftime("%Y-%m-%d") for d in pd.to_datetime(df.index)]
#     # define dates with missing values
#     dt_breaks = [d for d in dt_all.strftime("%Y-%m-%d").tolist() if not d in dt_obs]
#
#     return dt_breaks
#
#
# dt_breaks = get_break(datas)
#
# # fig = go.Figure(data = data, layout = layout)
# # fig.update_xaxes(rangebreaks=[dict(values=dt_breaks)])
#
# # py.offline.iplot(data, filename = 'first_offline_start')
#
# # fig = go.Figure()
# # fig.add_trace( go.Candlestick(x=datas.index,
# #                          open=datas['open'],
# #                          high=datas['high'],
# #                          low=datas['low'],
# #                          close=datas['close'],
# #                          showlegend=True,
# #                         increasing_line_color='red',
# #                         decreasing_line_color='green',
# #                          name='k line')
# #              )
#
# qf = cf.QuantFig(datas, title='第一定量图', legend='top', name='GS')
# # qf.add_bollinger_bands()
# # qf.add_dmi(periods=5)
# # a = qf.iplot(layout=layout, asFigure=True)
#
# go.Figure()
#
# fig = qf.iplot(asFigure=True)
#
# # datas['sma_5'] = datas['close'].rolling(window=5).mean()
# # # 添加5日移动平均线作为折线图
# # fig.add_trace(go.Scatter(x=datas.index, y=datas['sma_5'], showlegend=True, line=dict(color='red'), name='5 Day SMA', yaxis='y4'))
#
# datas['sma_5'] = datas['close'].rolling(window=5).mean()
# # 添加5日移动平均线作为折线图
# fig.add_trace(
#     go.Scatter(x=datas.index, y=datas['sma_5'], showlegend=True, line=dict(color='red'), name='5 Day SMA', yaxis='y2'))
#
#
# # print(fig.layout.to_json())
#
# # for trace in fig.data:
# #     print(trace)
#
# # 打印每个子图的行数和列数
# # for i, trace in enumerate(fig.data):
# #     row_num, col_num = fig._grid_ref[i]['row'], fig._grid_ref[i]['col']
# #     print(f"Trace {i+1} is located at row {row_num} and column {col_num}")
#
# # print(fig.data[0])
# # print(fig.data[1])
# # print(fig.data[0].name)
# # print(fig.data[1].name)
#
#
# # print(fig.data[2])
#
# fig.update_layout(xaxis_rangeslider_visible=False)
# fig.update_xaxes(rangebreaks=[dict(values=dt_breaks)])
#
# pt_iplot(fig)
#
# # fig.update_layout(xaxis_rangeslider_visible=False)
# # fig.update_xaxes(rangebreaks=[dict(values=dt_breaks)])
# # py.offline.iplot(fig, filename = 'first_offline_start')
#
#
#
# import plotly.express as px
# fig = px.bar(x=['a', 'b', 'c'], y=[1, 3, 2])
# fig.show()

import plotly as py
import plotly.graph_objs as go


def display_plotly_fig_info(fig:go.Figure):
    print(fig)

    for i, data in enumerate(fig.data):
        print(data)

    print(fig.layout)
    # print(fig.layout)
